package sk.naive.talker.server;

import sk.naive.talker.*;
import sk.naive.talker.props.RemotePropertyConfiguration;
import sk.naive.talker.callback.CallbackResult;
import sk.naive.talker.persistence.PersistenceException;
import sk.naive.talker.adapter.*;

import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;

/**
 * TalkerServer implements RemoteTalker services.
 * <p>
 * All operations are delegated to Talker.
 * <p>
 * <i>This separation of roles RMI server/talker is implemented because
 * RMI server needs to extend UnicastRemoteObject and Talker needs to
 * extend AbstractPersistentObject.</i>
 *
 * @author <a href="mailto:virgo@naive.deepblue.sk">Richard "Virgo" Richter</a>
 * @version $Revision: 1.5 $ $Date: 2004/10/10 19:46:10 $
 */
public class TalkerServer extends UnicastRemoteObject
	implements RemoteTalker
{
	private Talker talker;

	public TalkerServer(Talker talker) throws RemoteException {
		this.talker = talker;
	}

	public void registerAdapter(Adapter adapter, RemotePropertyConfiguration rpc) throws RemoteException {
		talker.registerAdapter(adapter, rpc);
	}

	public void deregisterAdapter(Adapter adapter) throws RemoteException {
		talker.deregisterAdapter(adapter);
	}

	public void userIn(AdapterUser u) throws RemoteException, AuthenticationException, PersistenceException {
		talker.userIn(u);
	}

	public void userOut(AdapterUser u) throws RemoteException {
		talker.userOut(u);
	}

	public void processUserMessage(AdapterUser u, String message) throws RemoteException {
		talker.processUserMessage(u, message);
	}

	public String processSystemMessage(String message) throws RemoteException {
		return talker.processSystemMessage(message);
	}

	public void processUserCallback(AdapterUser u, CallbackResult result) throws RemoteException {
		talker.processUserCallback(u, result);
	}
}